#include <iostream>
#include <string.h>
#include <list>
#include <memory>
using namespace std;

class b;

class a
{
public:
    ~a()
    {
        cout<<"a的析构函数"<<endl;
    }
    weak_ptr<b> pb;
};

class b
{
public:
    ~b()
    {
        cout<<"b的析构函数"<<endl;
    }
    weak_ptr<a> pa;
};

int main()
{
    shared_ptr<a> pa = make_shared<a>();
    shared_ptr<b> pb = make_shared<b>();
    weak_ptr<a> wpa = pa;
    pa->pb = pb;//pa里面的pb指向了pb
    pb->pa = pa;//pb里面的pa指向了pa

    cout<<"pa:"<<pa.use_count()<<endl;
    cout<<"pb:"<<pb.use_count()<<endl;
    return 0;
}
